using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Windows.Forms;


namespace CSDesktopUsiXMLRenderer
{
    class UsiXMLInterfaceRenderer
    {
        private UsiXMLElementRenderer mainWindowRenderer = null;
        private ResourceRetriever resourceRetriever = null;

        public UsiXMLInterfaceRenderer()
        {
            this.mainWindowRenderer = new UsiXMLWindowRenderer();
            this.mainWindowRenderer.setInterfaceRenderer(this);
            
            
        }

        public void renderInterface(XmlNode cuiModel, XmlNode resourceModel)
        {
            this.resourceRetriever = new ResourceRetriever(resourceModel);

            XmlNode window = null;

            foreach (XmlNode node in cuiModel.ChildNodes)
            {
                if (node.Name == "window")
                {
                    window = node;
                }
            }


            Form mainForm = (Form)this.mainWindowRenderer.renderElement(window);
            mainForm.ShowDialog();
        }

        public ResourceRetriever getResourceRetriever()
        {
            return this.resourceRetriever;
        }
    }
}
